package edu.cmu.cs.erl.unitTests;

import java.util.ArrayList;
import java.util.List;

import jp.ac.kobe_u.cs.prolog.lang.Term;
import jp.ac.kobe_u.cs.prolog.lang.VariableTerm;

import org.junit.Assert;
import org.junit.Test;

import edu.cmu.cs.erl.ERL;
import edu.cmu.cs.erl.ERLError;
import edu.cmu.cs.erl.ERLException;
import edu.cmu.cs.erl.Oracle;
import edu.cmu.cs.erl.TermBuilder;

public class NotTest {
	@Test
	public void NotAndTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notandTerm = TermBuilder.createNotTerm(TermBuilder.createAndTerm(TermBuilder.createAtomicTerm("b"),TermBuilder.createAtomicTerm("a")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notandTerm, true);
		
		Assert.assertTrue(errors.isEmpty());
	}
	@Test
	public void NotAndFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notandTerm = TermBuilder.createNotTerm(TermBuilder.createAndTerm(TermBuilder.createAtomicTerm("a"),TermBuilder.createAtomicTerm("a")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notandTerm, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}
	@Test
	public void NotOrTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notorTerm = TermBuilder.createNotTerm(TermBuilder.createOrTerm(TermBuilder.createAtomicTerm("b"),TermBuilder.createAtomicTerm("b")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notorTerm, true);
		
		Assert.assertTrue(errors.isEmpty());
	}
	@Test
	public void NotOrFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notorTerm = TermBuilder.createNotTerm(TermBuilder.createOrTerm(TermBuilder.createAtomicTerm("b"),TermBuilder.createAtomicTerm("a")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notorTerm, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}
	
	@Test
	public void NotNotTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notnotTerm = TermBuilder.createNotTerm(TermBuilder.createNotTerm(TermBuilder.createAtomicTerm("a")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notnotTerm, true);
		
		Assert.assertTrue(errors.isEmpty());
	}
	@Test
	public void NotNotFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notnotTerm = TermBuilder.createNotTerm(TermBuilder.createNotTerm(TermBuilder.createAtomicTerm("b")));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notnotTerm, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}
	@Test
	public void NotAtTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notatTerm = TermBuilder.createNotTerm(TermBuilder.createAtomicTerm("b"));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notatTerm, true);
		
		Assert.assertTrue(errors.isEmpty());
	}
	@Test
	public void NotAtFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		Term notatTerm = TermBuilder.createNotTerm(TermBuilder.createAtomicTerm("a"));
		
		List<ERLError> errors = ERL.runPredicate(oracle, notatTerm, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}
	@Test
	public void NotExistsTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		
		VariableTerm X = (VariableTerm)TermBuilder.createVariableTerm();
		Term term1 = TermBuilder.createAtomicTerm(X);
		Term term2 = TermBuilder.createAtomicTerm("a");
		Term andTerm = TermBuilder.createAndTerm(term1, term2);
		
		ArrayList<String> list = new ArrayList<String>();
		list.add("b");
		list.add("b");
		list.add("b");
		
		Term exists = TermBuilder.createExistsTerm(list,X,andTerm);
		Term notexists = TermBuilder.createNotTerm(exists);
		List<ERLError> errors = ERL.runPredicate(oracle, notexists, true);
		
		Assert.assertTrue(errors.isEmpty());
	}
	@Test
	public void NotExistsFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		
		VariableTerm X = (VariableTerm)TermBuilder.createVariableTerm();
		Term term1 = TermBuilder.createAtomicTerm(X);
		Term term2 = TermBuilder.createAtomicTerm("a");
		Term andTerm = TermBuilder.createAndTerm(term1, term2);
		
		ArrayList<String> list = new ArrayList<String>();
		list.add("a");
		list.add("b");
		list.add("b");
		
		Term exists = TermBuilder.createExistsTerm(list,X,andTerm);
		Term notexists = TermBuilder.createNotTerm(exists);
		List<ERLError> errors = ERL.runPredicate(oracle, notexists, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}
	/*@Test
	public void NotForallTTest() throws ERLException {
		Oracle oracle = new TestOracle();
		
		VariableTerm X = (VariableTerm)TermBuilder.createVariableTerm();
		Term term1 = TermBuilder.createAtomicTerm(X);
		Term term2 = TermBuilder.createAtomicTerm("a");
		Term andTerm = TermBuilder.createAndTerm(term1, term2);
		
		ArrayList<String> list = new ArrayList<String>();
		list.add("a");
		list.add("b");
		list.add("c");
		
		Term forAll = TermBuilder.createForAllTerm(list,X,andTerm);
		Term notforAll = TermBuilder.createNotTerm(forAll);
		List<ERLError> errors = ERL.runPredicate(oracle, notforAll, true);
		
		Assert.assertTrue(errors.isEmpty());
	}*/
	/*@Test
	public void NotForallFTest() throws ERLException {
		Oracle oracle = new TestOracle();
		
		VariableTerm X = (VariableTerm)TermBuilder.createVariableTerm();
		Term term1 = TermBuilder.createAtomicTerm(X);
		Term term2 = TermBuilder.createAtomicTerm("a");
		Term andTerm = TermBuilder.createAndTerm(term1, term2);
		
		ArrayList<String> list = new ArrayList<String>();
		list.add("a");
		list.add("a");
		list.add("a");
		
		Term forAll = TermBuilder.createForAllTerm(list,X,andTerm);
		Term notforAll = TermBuilder.createNotTerm(forAll);
		List<ERLError> errors = ERL.runPredicate(oracle, notforAll, true);
		
		Assert.assertTrue(!errors.isEmpty());
	}*/
}
